package longcaisuyun.longcai.com.net;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.suyunbean.CardBean;

/**
 * Created by Administrator on 2016/4/27.
 */
@HttpInlet(Net.CARD)
public class PostYinHangList extends WHAsyPost<PostYinHangList.Info> {
    public String driverid;

    public PostYinHangList(String driverid, AsyCallBack asyCallBack) {
        super(asyCallBack);
        this.driverid = driverid;
    }

    @Override
    protected Info parser(JSONObject object) {
        Info info = new Info();
        try {
            info.message = object.getString("message");
            if (info.message.equals("1")) {
                for (int j = 0; j < object.getJSONArray("list").length(); j++) {
                    CardBean cardBean = new CardBean();
                    cardBean.setId(object.getJSONArray("list").getJSONObject(j).getString("id"));
                    cardBean.setName(object.getJSONArray("list").getJSONObject(j).getString("name"));
                    cardBean.setBankcard(object.getJSONArray("list").getJSONObject(j).getString("bankcard"));
                    cardBean.setBanktype(object.getJSONArray("list").getJSONObject(j).getString("banktype"));
                    cardBean.setMobile(object.getJSONArray("list").getJSONObject(j).getString("mobile"));
                    info.list.add(cardBean);
                }
            }
            return   info;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static class Info {
        public String message;
        public List<CardBean> list = new ArrayList();
    }
}
